package com.mxpio.erp.common.inventory.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.mxpio.erp.common.jpa.model.Order;
import com.mxpioframework.security.annotation.Dict;
import com.mxpioframework.security.entity.Dept;
import com.mxpioframework.security.entity.User;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;
import java.util.List;

/**
 * @Author : wpp
 * @Datetime : 2023/12/7 13:43
 * @Desc :
 * @Modor :  Modifytime:
 * @modDesc :
 */
@Data
@EqualsAndHashCode(callSuper=false)
@Entity
@Table(name = "MB_ERP_INV_BR")
@Schema(description = "借还申请单")
public class BorrowApply extends Order {

    @Column(name = "RETURN_STATUS_")
    @Schema(description = "归还状态")
    @Dict(dicCode = "ERP_INV_BORROW_RETURN_STATUS")//
    private String returnStatus;

    @Column(name = "BORROWER_")
    @Schema(description = "借用人")
    @Dict(dicCode = "username", dicEntity = User.class, dicText = "nickname")
    private String borrower;

    @Column(name = "APPLY_DEPT_")
    @Schema(description = "申请部门")
    @Dict(dicCode = "deptCode", dicEntity = Dept.class, dicText = "deptName")
    private String applyDept;

    @Column(name = "BORROW_TIME_")
    @Schema(description = "借出时间")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date borrowTime;

    @Column(name = "PLAN_RETURN_TIME_")
    @Schema(description = "预计归还时间")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date planReturnTime;

    @Column(name = "ACTUAL_RETURN_TIME_")
    @Schema(description = "归还时间")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date actualReturnTime;

    @Column(name = "MEMO_")
    @Schema(description = "备注")
    private String memo;

    @Column(name = "WH_CODE_")
    @Schema(description = "物品仓库编号")
    @Dict(dicCode = "whCode" ,dicEntity = Warehouse.class, dicText = "whName")
    private String whCode;
    @Override
    public String initTypeCode() {
        return "BW1";
    }

    @Transient
    private List<BorrowApplyLine> lineList;
}
